package com.patsnap.data.npd.dw.handler;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.PropertyNamingStrategy;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.patsnap.one.etl.mybaties.type.handler.GenericFastjsonTypeHandler;

import java.lang.reflect.Type;

public class NoNullFastjsonTypeHandler extends GenericFastjsonTypeHandler {

    private static final SerializeConfig config = new SerializeConfig();

    static {
        config.setPropertyNamingStrategy(PropertyNamingStrategy.SnakeCase);
    }

    public NoNullFastjsonTypeHandler(Type type) {
        super(type);
    }

    public NoNullFastjsonTypeHandler(Class<?> type) {
        super(type);
    }

    @Override
    protected String toJson(Object obj) {
        return JSON.toJSONString(obj, config);
    }
}
